/*
同步数据库 模型同步数据库
注意:使用{force:true} 每次同步数据结构会情况数据，生产数据请谨慎操作。
// const { user } = require("../entity/user");
// user.sync({force: true});
 */
const _ = require('lodash')
const path = require('path');
//const { traverseDir } = require('../Utils/file')
let parentDir = path.resolve(path.dirname(__filename), '../');
//let list = [];
//traverseDir(parentDir + '/entity',list,'folder');

require('require-all')({
    dirname: parentDir + '/entity',
    filter: /(.+)\.js$/,
    recursive: true,
    resolve:async function (entity) {
        await entity.sync({force: true});
        if(entity['name'] === 'user'){
            entity.create({
                name: "admin",
                age: "18",
                account: "admin",
                password: "123456",
              });
        }
    }
});

